package com.talkweb.yingu.apimodel.common;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by qsf on 2019/4/3.
 */
@Setter
@Getter
@ToString
public class ResponseResult<T> {
    public Status status;   //消息状态
    public String message;   //消息描述
    public List<T> dataList = new ArrayList<>(); //返回数据列表
    public T data;  //返回单条数据
    public Integer count;   //分页查询时数据总数

    /**
     * 是否成功
     */
    public static Boolean isSuccess(ResponseResult response) {
        if(response.getStatus().getValue().equals(Status.SUCCESS.getValue())) {
            return true;
        }else {
            return false;
        }
    }

    public Boolean isSuccess() {
        if(status.getValue().equals(Status.SUCCESS.getValue())) {
            return true;
        }else {
            return  false;
        }
    }

    public ResponseResult () {
        this.status=Status.SUCCESS;
        this.message="成功";
    }
}
